﻿using Microsoft.AspNetCore.Mvc;
using Step4.Unit6.Serilog.Models;
using System.Diagnostics;

namespace Step4.Unit6.Serilog.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// 测试Serilog
        /// </summary>
        /// <returns></returns>
        public IActionResult SerilogTest()
        {
            // 输出不同级别的日志
            _logger.LogTrace("trance日志测试");
            _logger.LogDebug("debug日志测试");
            _logger.LogInformation("information日志测试");
            _logger.LogWarning("warning日志测试");
            _logger.LogError("error日志测试");
            return View();
        }


        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
